package com.sbj.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sbj.dto.req.OrderReq;
import com.sbj.dto.res.OrderRes;
import com.sbj.dto.res.ShopOrderRes;
import com.sbj.entity.KdModel;
import com.sbj.service.KdService;
import com.sbj.service.OrderKdService;
import com.sbj.service.OrderService;
import com.zmh.framework.config.BaseCommonInterface;
import com.zmh.framework.util.Result;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;
import java.util.Map;

/**
 * @author summer
 * @version 1.0
 * @date 2024/9/10 09:05
 */
@RestController
@RequestMapping(value = "/order")
@AllArgsConstructor
public class OrderController implements BaseCommonInterface<OrderReq, ShopOrderRes> {

    private final OrderService orderService;

    @Override
    public Result<String> save(@Valid OrderReq orderReq) {
        orderService.orderDeliver(orderReq);
        return Result.successResult();
    }

    @Override
    public Result<String> del(Integer integer) {
        return null;
    }

    @Override
    public Result<Page<ShopOrderRes>> lists(OrderReq orderReq) {
        return Result.successResult(orderService.lists(orderReq));
    }

    @Override
    public Result<ShopOrderRes> findById(Integer integer) {
        return null;
    }

    @Override
    public Result<String> batchDel(List<ShopOrderRes> list) {
        return null;
    }

    private final KdService kdService;

    @GetMapping(value = "/kdList")
    public Result<List<KdModel>> kdList(){

        return Result.successResult(kdService.list());
    }
    private final OrderKdService orderKdService;

    @GetMapping(value = "/kdInfo/{orderId}")
    public Result<Map<String,Object>> kdInfo(@PathVariable Integer orderId){
        return Result.successResult(orderKdService.kdInfo(orderId));
    }

}
